/**
 * Created by hjqi on 2016/3/28.
 */

var base = require('./mongodb');
var util = require('util');
var serviceMetaInfo_collection_name = require('../lib/config/config').config.mongodb.job_collection;

module.exports = serviceMetaInfoDB;

function serviceMetaInfoDB(){
    base.call(this,serviceMetaInfo_collection_name);
}

util.inherits(serviceMetaInfoDB,base);
//主键确保有唯一索引

/*
 serviceInfo.schema
 db.serviceInfo.findOne()
 {
 "_id" : ObjectId("57a84b4ff00b10fc4401a4dc"),
 "app" : "webshell",
 "id" : "webshell",
 "node" : {
 "image" : "prod.internal.naturecloud.io/system/webshell:0.4",
 "imageshortname" : "webshell",
 "isMarket" : false,
 "ports" : [{
 "isPublic" : true,
 "port" : 3006,
 "targetPort" : 3006,
 "protocol" : "TCP",
 "accessProtocol" : "TCP",
 "address" : "121.42.140.164:31811",
 "nodePort" : 31811
 }
 ],
 "env" : [],
 "cpu_shares" : "0.25",
 "mem_limit" : "256Mi",
 "volumes" : [{
 "IsDefault" : false,
 "mountTargetPath" : "/work/webshell-server/config",
 "mountObj" : {
 "_id" : ObjectId("57a5df559b0625ac4f92333f"),
 "job" : {
 "apiVersion" : "batch/v1",
 "kind" : "Job",
 "metadata" : {
 "name" : "d2d4d8ad1c898e16c08006a2",
 "labels" : {
 "app" : "d2d4d8ad1c898e16c08006a2"
 }
 },
 "spec" : {
 "selector" : {
 "app" : "d2d4d8ad1c898e16c08006a2"
 },
 "activeDeadlineSeconds" : 300,
 "template" : {
 "metadata" : {
 "name" : "d2d4d8ad1c898e16c08006a2",
 "labels" : {
 "app" : "d2d4d8ad1c898e16c08006a2"
 }
 },
 "spec" : {
 "containers" : [{
 "name" : "d2d4d8ad1c898e16c08006a2",
 "image" : "naturecloud.io/library/volume-explorer",
 "ports" : [{
 "containerPort" : 80,
 "protocol" : "TCP"
 }
 ],
 "volumeMounts" : [{
 "name" : "datavolume",
 "mountPath" : "/data"
 }
 ],
 "imagePullPolicy" : "IfNotPresent"
 }
 ],
 "volumes" : [{
 "name" : "datavolume",
 "glusterfs" : {
 "endpoints" : "glusterfs-cluster",
 "path" : "system-webshellconfig"
 }
 }
 ],
 "restartPolicy" : "Never"
 }
 }
 }
 },
 "mountAppName" : "",
 "mountNodeName" : "",
 "name" : "webshellconfig",
 "namespace" : "system",
 "size" : 1024,
 "status" : "NOT_USE",
 "svc" : {
 "kind" : "Service",
 "apiVersion" : "v1",
 "metadata" : {
 "name" : "d2d4d8ad1c898e16c08006a2",
 "labels" : {
 "app" : "d2d4d8ad1c898e16c08006a2"
 }
 },
 "spec" : {
 "selector" : {
 "app" : "d2d4d8ad1c898e16c08006a2"
 },
 "type" : "ClusterIP",
 "ports" : [{
 "name" : "0",
 "protocol" : "TCP",
 "port" : 80,
 "targetPort" : 80
 }
 ]
 }
 },
 "svcId" : "d2d4d8ad1c898e16c08006a2",
 "volumeId" : "system-webshellconfig"
 }
 }, {
 "IsDefault" : false,
 "mountTargetPath" : "/work/webshell-server/logs",
 "mountObj" : {
 "name" : "webshell-work-webshell-server-logs",
 "volumeId" : "system-webshell-work-webshell-server-logs",
 "namespace" : "system",
 "status" : "NOT_USE",
 "mountAppName" : "",
 "mountNodeName" : "",
 "size" : 1024,
 "_id" : ObjectId("57a84b4ef00b10fc4401a4db")
 }
 }
 ]
 },
 "rc" : {
 "kind" : "ReplicationController",
 "apiVersion" : "v1",
 "metadata" : {
 "name" : "webshell-v0.4",
 "labels" : {
 "app" : "webshell",
 "version" : "0.4"
 }
 },
 "spec" : {
 "replicas" : 1,
 "template" : {
 "metadata" : {
 "labels" : {
 "app" : "webshell",
 "version" : "0.4"
 }
 },
 "spec" : {
 "containers" : [{
 "name" : "webshell",
 "image" : "prod.internal.naturecloud.io/system/webshell:0.4",
 "imagePullPolicy" : "IfNotPresent",
 "env" : [],
 "resources" : {
 "limits" : {
 "cpu" : "250m",
 "memory" : "256Mi"
 }
 },
 "ports" : [{
 "containerPort" : 3006,
 "protocol" : "TCP"
 }
 ],
 "volumeMounts" : [{
 "mountPath" : "/work/webshell-server/config",
 "name" : "webshellconfig"
 }, {
 "mountPath" : "/work/webshell-server/logs",
 "name" : "webshell-work-webshell-server-logs"
 }
 ]
 }
 ],
 "restartPolicy" : null,
 "terminationGracePeriodSeconds" : 0,
 "volumes" : [{
 "name" : "webshellconfig",
 "glusterfs" : {
 "endpoints" : "glusterfs-cluster",
 "path" : "system-webshellconfig"
 }
 }, {
 "name" : "webshell-work-webshell-server-logs",
 "glusterfs" : {
 "endpoints" : "glusterfs-cluster",
 "path" : "system-webshell-work-webshell-server-logs"
 }
 }
 ]
 }
 }
 }
 },
 "rcnum" : 1,
 "service" : {
 "kind" : "Service",
 "apiVersion" : "v1",
 "metadata" : {
 "name" : "webshell",
 "labels" : {
 "app" : "webshell"
 }
 },
 "spec" : {
 "selector" : {
 "app" : "webshell"
 },
 "type" : "NodePort",
 "ports" : [{
 "name" : "0",
 "protocol" : "TCP",
 "port" : 3006,
 "targetPort" : 3006
 }
 ]
 }
 },
 "totalStatue" : "starting",
 "username" : "system",
 "ver" : "0.4"
 }

 */